package net.oschina.j2chain;

import java.util.ArrayList;

/**
 * 激凸链
 * @author Winter Lau
 */
public class J2Chain {

    public final static int DIFFICULTY = 1;

    public static void main(String[] args) {

        var chain = new ArrayList<Block>();

        for(int i = 1; i <= 10; i++) {
            Block prevBlock = (chain.size()>0)?chain.get(chain.size()-1):null;
            String prevHash = (prevBlock != null)?prevBlock.getHash():null;
            Block block = new Block(prevHash, String.valueOf(i).getBytes());
            block.mine(DIFFICULTY);
            chain.add(block);
        }

        chain.forEach( b -> System.out.println(b));

    }

}
